package com.jl.jlapp.popu;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.GoodsMsgSpecificationAdapter;
import com.jl.jlapp.adapter.ShopCartPageGoodsSpecificationAdapter;
import com.jl.jlapp.eneity.GoodsDetailModel;

import java.util.ArrayList;
import java.util.List;

import static android.content.Context.LAYOUT_INFLATER_SERVICE;

public class ChooseGoodsSpecPopu
        extends PopupWindow {
    private TextView addShopCartBtn;
    private TextView buyNowBtn;
    String checkedGoodsSpec = "";
    Integer checkedGoodsSpecId = Integer.valueOf(0);
    private ImageView closeBtn;
    private GoodsMsgSpecificationAdapter goodsMsgSpecificationAdapter;
    private ImageView goodsSpecImg;
    private TextView goodsSpecNo;
    private TextView goodsSpecPrice;
    List<GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean> goodsSpecificationDetailsBeans;
    private RecyclerView goodsSpecificationRecyclerView;
    private Integer isFromGoodsOrShopCart = Integer.valueOf(-1);
    private Integer isPresell = Integer.valueOf(0);
    private TextView noGoodsNum;
    private TextView okBtn;
    private OnClickAddShopCartBtnListener onClickAddShopCartBtnListener;
    private OnClickBuyNowBtnListener onClickBuyNowBtnListener;
    private OnClickGoodsSpecItemListener onClickGoodsSpecItemListener;
    private OnClickOkBtnListener onClickOkBtnListener;
    private ShopCartPageGoodsSpecificationAdapter shopCartPageGoodsSpecificationAdapter;
    private TextView tReduce;
    private TextView textView;
    private TextView tvAdd;
    private EditText tvBuyNum;
    private View view;

    public ChooseGoodsSpecPopu(final Context paramContext, final String paramString, Integer paramInteger, final GoodsDetailModel.ResultDataBean paramResultDataBean) {
        super(paramContext);
        this.isFromGoodsOrShopCart = paramInteger;
        this.goodsSpecificationDetailsBeans = paramResultDataBean.getGoodsSpecificationDetails();
        ArrayList localArrayList = new ArrayList<GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean>();
        this.checkedGoodsSpec = paramString;
        this.view = ((LayoutInflater) paramContext.getSystemService(LAYOUT_INFLATER_SERVICE)).inflate(R.layout.choose_goods_spec_popup_layout, null);
        this.textView = ((TextView) this.view.findViewById(R.id.shadow_part));
        this.addShopCartBtn = ((TextView) this.view.findViewById(R.id.choose_spec_bottom_add_shop_cart));
        this.buyNowBtn = ((TextView) this.view.findViewById(R.id.choose_spec_bottom_buy_now));
        this.goodsSpecPrice = ((TextView) this.view.findViewById(R.id.goods_spec_price));
        this.goodsSpecNo = ((TextView) this.view.findViewById(R.id.goods_spec_no));
        this.goodsSpecImg = ((ImageView) this.view.findViewById(R.id.goods_spec_img));
        this.tvBuyNum = ((EditText) this.view.findViewById(R.id.tv_buy_num));
        this.tReduce = ((TextView) this.view.findViewById(R.id.tv_reduce));
        this.tvAdd = ((TextView) this.view.findViewById(R.id.tv_add));
        this.closeBtn = ((ImageView) this.view.findViewById(R.id.close_btn));
        this.noGoodsNum = ((TextView) this.view.findViewById(R.id.no_goods_num));
        this.noGoodsNum.setVisibility(View.GONE);
        this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.moreText));
        RelativeLayout relativeLayout = (RelativeLayout) this.view.findViewById(R.id.choose_spec_num_layout);
        this.goodsSpecificationRecyclerView = ((RecyclerView) this.view.findViewById(R.id.goods_spec_recycler_view));


        if (goodsSpecificationDetailsBeans != null && goodsSpecificationDetailsBeans.size() > 0) {


            if (this.checkedGoodsSpec.equals((this.goodsSpecificationDetailsBeans.get(0)).getSpecifications())) {
                this.isPresell = (this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsState();
                this.checkedGoodsSpecId = this.goodsSpecificationDetailsBeans.get(0).getId();
                this.goodsSpecPrice.setText((this.goodsSpecificationDetailsBeans.get(0)).getPrice() + "");
                this.goodsSpecNo.setText((this.goodsSpecificationDetailsBeans.get(0)).getIdentifier());
                if ((this.goodsSpecificationDetailsBeans.get(0)).getGoodsDisplayPictures().size() > 0) {
                    String str = this.goodsSpecificationDetailsBeans.get(0).getGoodsDisplayPictures().get(0).getPicUrl();
                    Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + str).into(this.goodsSpecImg);
                }
            } else {
                if ((paramResultDataBean.getZeroStock() != 0) || (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsState() != 2)) {
                }
                if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsStock() <= 0) {
                    localArrayList.add(this.goodsSpecificationDetailsBeans.get(0));
                }
                if (Integer.parseInt(this.tvBuyNum.getText().toString().trim()) < ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsStock()) {
                }
                this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
            }


            this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.moreText));
            Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load(R.drawable.img_noimg_xs).into(this.goodsSpecImg);
            this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
            this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));

        }

        int i = 0;

//        if (localArrayList.size() > 0) {
//            i = 0;
//            if (i < this.goodsSpecificationDetailsBeans.size()) {
//                int j = 0;
//                for (; ; ) {
//                    int k = i;
//                    if (j < localArrayList.size()) {
//                        if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(i)).getId() == ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) localArrayList.get(j)).getId()) {
//                            this.goodsSpecificationDetailsBeans.remove(i);
//                            this.goodsSpecificationDetailsBeans.add(localArrayList.get(j));
//                            localArrayList.remove(j);
//                            k = i - 1;
//                        }
//                    } else {
//                        i = k + 1;
//                        break;
//                    }
//                    j += 1;
//                }
//            }
//        }
        if (paramInteger == 0) {
//            paramString.setVisibility(View.VISIBLE);
            this.goodsSpecificationRecyclerView.setLayoutManager(new GridLayoutManager(paramContext, 3));
            this.goodsMsgSpecificationAdapter = new GoodsMsgSpecificationAdapter(R.layout.choose_goods_spec_item, this.goodsSpecificationDetailsBeans);
            this.goodsMsgSpecificationAdapter.setCheckedGoodsSpc(this.checkedGoodsSpec);
            this.goodsSpecificationRecyclerView.setAdapter(this.goodsMsgSpecificationAdapter);
            this.goodsMsgSpecificationAdapter.setOnItemClickListener(new OnItemClickListener() {
                public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
                    TextView tvDetail = (TextView) paramAnonymousView.findViewById(R.id.goods_spec_detail);
                    tvDetail.setBackgroundResource(R.drawable.bg_text_green_border);
                    label535:
                    if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getGxcGoodsStock() <= 0) {
                        if ((paramResultDataBean.getZeroStock() == 0) && (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getGxcGoodsState() == 2)) {
//                            ChooseGoodsSpecPopu.access$002(ChooseGoodsSpecPopu.this, Integer.valueOf(2));
                            ChooseGoodsSpecPopu.this.noGoodsNum.setVisibility(View.VISIBLE);
                            ChooseGoodsSpecPopu.this.addShopCartBtn.setBackgroundResource(R.color.moreText);
                            ChooseGoodsSpecPopu.this.buyNowBtn.setBackgroundResource(R.color.moreText);
                            ChooseGoodsSpecPopu.this.addShopCartBtn.setEnabled(false);
                            ChooseGoodsSpecPopu.this.buyNowBtn.setEnabled(false);
//                            paramString.setVisibility(View.GONE);
                            if (("".equals(ChooseGoodsSpecPopu.this.checkedGoodsSpec)) || (!ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(tvDetail.getText().toString().trim()))) {
                                ChooseGoodsSpecPopu.this.checkedGoodsSpec = tvDetail.getText().toString().trim();
                                ChooseGoodsSpecPopu.this.checkedGoodsSpecId = Integer.valueOf(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getId());
                                ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.setCheckedGoodsSpc(ChooseGoodsSpecPopu.this.checkedGoodsSpec);
                                ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.notifyDataSetChanged();
                                paramAnonymousInt = 0;
                                if (paramAnonymousInt < ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size()) {
                                    if (ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getSpecifications())) {
                                        ChooseGoodsSpecPopu.this.goodsSpecPrice.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getPrice() + "");
                                        ChooseGoodsSpecPopu.this.goodsSpecNo.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getIdentifier());
                                        if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getGoodsDisplayPictures().size() <= 0) {
                                        }
                                        String picUrl = ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getGoodsDisplayPictures().get(0)).getPicUrl();
                                        Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + picUrl).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                    } else {
                                        paramAnonymousInt += 1;
                                        Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load(R.drawable.img_noimg_xs).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                    }
                                }
                            }
                        } else {
//                            ChooseGoodsSpecPopu.access$002(ChooseGoodsSpecPopu.this, Integer.valueOf(1));
                            ChooseGoodsSpecPopu.this.noGoodsNum.setVisibility(View.GONE);
                            ChooseGoodsSpecPopu.this.addShopCartBtn.setBackgroundResource(R.color.checkGreenColor);
                            ChooseGoodsSpecPopu.this.buyNowBtn.setBackgroundResource(R.color.orange);
                            ChooseGoodsSpecPopu.this.addShopCartBtn.setEnabled(true);
                            ChooseGoodsSpecPopu.this.buyNowBtn.setEnabled(true);
//                            paramString.setVisibility(View.VISIBLE);
                            if (("".equals(ChooseGoodsSpecPopu.this.checkedGoodsSpec)) || (!ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(tvDetail.getText().toString().trim()))) {
                                ChooseGoodsSpecPopu.this.checkedGoodsSpec = tvDetail.getText().toString().trim();
                                ChooseGoodsSpecPopu.this.checkedGoodsSpecId = Integer.valueOf(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getId());
                                ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.setCheckedGoodsSpc(ChooseGoodsSpecPopu.this.checkedGoodsSpec);
                                ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.notifyDataSetChanged();
                                if (ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size() > 0) {
                                    if (ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getSpecifications())) {
                                        ChooseGoodsSpecPopu.this.goodsSpecPrice.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getPrice() + "");
                                        ChooseGoodsSpecPopu.this.goodsSpecNo.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getIdentifier());
                                        if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getGoodsDisplayPictures().size() <= 0) {
                                        }
                                        String picUrl = ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getGoodsDisplayPictures().get(0)).getPicUrl();
                                        Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + picUrl).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                    } else {
                                        if (ChooseGoodsSpecPopu.this.onClickGoodsSpecItemListener != null) {
                                            ChooseGoodsSpecPopu.this.onClickGoodsSpecItemListener.OnClickGoodsSpecItem(ChooseGoodsSpecPopu.this.checkedGoodsSpec, ChooseGoodsSpecPopu.this.checkedGoodsSpecId, Integer.valueOf(paramAnonymousInt));
                                        }
                                        Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load(Integer.valueOf(R.drawable.img_noimg_xs)).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                    }
                                }
                            }
                        }
                    } else {
                        ChooseGoodsSpecPopu.this.noGoodsNum.setVisibility(View.GONE);
                        ChooseGoodsSpecPopu.this.addShopCartBtn.setBackgroundResource(R.color.checkGreenColor);
                        ChooseGoodsSpecPopu.this.buyNowBtn.setBackgroundResource(R.color.orange);
                        ChooseGoodsSpecPopu.this.addShopCartBtn.setEnabled(true);
                        ChooseGoodsSpecPopu.this.buyNowBtn.setEnabled(true);
//                        paramString.setVisibility(View.VISIBLE);
                        if (("".equals(ChooseGoodsSpecPopu.this.checkedGoodsSpec)) || (!ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(tvDetail.getText().toString().trim()))) {
//                            ChooseGoodsSpecPopu.access$002(ChooseGoodsSpecPopu.this, Integer.valueOf(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getGxcGoodsState()));
                            ChooseGoodsSpecPopu.this.checkedGoodsSpec = tvDetail.getText().toString().trim();
                            ChooseGoodsSpecPopu.this.checkedGoodsSpecId = Integer.valueOf(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(paramAnonymousInt)).getId());
                            ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.setCheckedGoodsSpc(ChooseGoodsSpecPopu.this.checkedGoodsSpec);
                            ChooseGoodsSpecPopu.this.goodsMsgSpecificationAdapter.notifyDataSetChanged();
//                            i = 0;
                            if (ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size() > 0) {
                                if (ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getSpecifications())) {
                                    ChooseGoodsSpecPopu.this.goodsSpecPrice.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getPrice() + "");
                                    ChooseGoodsSpecPopu.this.goodsSpecNo.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getIdentifier());
                                    if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getGoodsDisplayPictures().size() <= 0) {
                                        String picUrl = ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(0)).getGoodsDisplayPictures().get(0)).getPicUrl();
                                        Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + picUrl).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                    }
                                } else {
                                    if (ChooseGoodsSpecPopu.this.onClickGoodsSpecItemListener != null) {
                                        ChooseGoodsSpecPopu.this.onClickGoodsSpecItemListener.OnClickGoodsSpecItem(ChooseGoodsSpecPopu.this.checkedGoodsSpec, ChooseGoodsSpecPopu.this.checkedGoodsSpecId, Integer.valueOf(paramAnonymousInt));
                                    }
                                    Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load(R.drawable.img_noimg_xs).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
                                }
                            }
                        }
                    }
                }
            });
            if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsStock() > 0) {

            }
            if ((paramResultDataBean.getZeroStock() != 0) || (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) this.goodsSpecificationDetailsBeans.get(0)).getGxcGoodsState() != 2)) {
            }
            this.noGoodsNum.setVisibility(View.VISIBLE);
            this.addShopCartBtn.setBackgroundResource(R.color.moreText);
            this.buyNowBtn.setBackgroundResource(R.color.moreText);
            this.addShopCartBtn.setEnabled(false);
            this.buyNowBtn.setEnabled(false);
//            paramString.setVisibility(View.GONE);
        }
        for (; ; ) {
            this.tvAdd.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    if (!"".equals(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())) {
                        int j = Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim());
                        if (j >= 500) {
                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                            ChooseGoodsSpecPopu.this.tvBuyNum.setText("500");
                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                        } else {
//                            while (i < ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size()) {
//                                if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getId() == ChooseGoodsSpecPopu.this.checkedGoodsSpecId.intValue()) {
//                                    if ((paramResultDataBean.getZeroStock() != 0) || (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsState() != 2)) {
//                                    }
//                                    if (j < ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsStock()) {
//                                    }
//                                    Toast.makeText(paramContext, "已到库存上限!", Toast.LENGTH_SHORT).show();
//                                    ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
//                                }
//                                i += 1;
//                            }
                        }
//                        label256:
//                        ChooseGoodsSpecPopu.this.tvBuyNum.setText(j + 1 + "");
//                        if (j + 1 == 500) {
//                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
//                        }
//                        for (; ; ) {
//                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
//                            break;
//                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
//                        }
//                        label368:
//                        ChooseGoodsSpecPopu.this.tvBuyNum.setText(j + 1 + "");
//                        if (j + 1 == 500) {
//                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
//                        }
//                        for (; ; ) {
//                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
//                            break;
//                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
//                        }
                    }
                    Toast.makeText(paramContext, "请输入购买数量", Toast.LENGTH_SHORT).show();
                }
            });
            this.tvBuyNum.setInputType(3);
            this.tvBuyNum.setInputType(2);
            this.tvBuyNum.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable paramAnonymousEditable) {
                    if (!"".equals(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())) {
                        if (Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim()) <= 0) {
                            ChooseGoodsSpecPopu.this.tvBuyNum.setText("1");
                        }
                        if (Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim()) > 1) {
                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                        }
                        int i = 0;
                        if (i < ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size()) {
                            if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getId() == ChooseGoodsSpecPopu.this.checkedGoodsSpecId.intValue()) {
                                if ((paramResultDataBean.getZeroStock() != 0) || (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsState() != 2)) {
                                }
                                if (Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim()) <= ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsStock()) {
                                }
                                Toast.makeText(paramContext, "库存上限为" + ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsStock(), Toast.LENGTH_SHORT).show();
                                ChooseGoodsSpecPopu.this.tvBuyNum.setText(((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsStock() + "");
                                ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                            } else {
                                if (Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim()) > 500) {
                                    ChooseGoodsSpecPopu.this.tvBuyNum.setText("500");
                                    ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                                } else {
                                    ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                                    if (Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim()) > 500) {
                                        ChooseGoodsSpecPopu.this.tvBuyNum.setText("500");
                                        ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                                    } else {
                                        ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                                    }
                                }
                            }
                        }
                    }
                }

                public void beforeTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {
                }

                public void onTextChanged(CharSequence paramAnonymousCharSequence, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3) {
                }
            });
            this.tReduce.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    if (!"".equals(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())) {
                        int j = Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim());
                        if (j <= 1) {
                            Toast.makeText(paramContext, "不能再减少了!", Toast.LENGTH_SHORT).show();
                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                        }

                        ChooseGoodsSpecPopu.this.tvBuyNum.setText(j - 1 + "");
                        if (j - 1 == 1) {
                            ChooseGoodsSpecPopu.this.tReduce.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                        }

                        int i = 0;
                        if (i < ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.size()) {
                            if (((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getId() == ChooseGoodsSpecPopu.this.checkedGoodsSpecId.intValue()) {
                                if (j - 1 >= ((GoodsDetailModel.ResultDataBean.GoodsSpecificationDetailsBean) ChooseGoodsSpecPopu.this.goodsSpecificationDetailsBeans.get(i)).getGxcGoodsStock()) {
                                }
                                ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.trans_333333));
                            }
                        } else {
                            ChooseGoodsSpecPopu.this.tvAdd.setTextColor(paramContext.getResources().getColor(R.color.moreText));
                        }
                    }
                    Toast.makeText(paramContext, "请输入购买数量", Toast.LENGTH_SHORT).show();
                }
            });
            this.addShopCartBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    if (!"".equals(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())) {
                        if (ChooseGoodsSpecPopu.this.onClickAddShopCartBtnListener != null) {
                            ChooseGoodsSpecPopu.this.onClickAddShopCartBtnListener.OnClickAddShopCartBtn(ChooseGoodsSpecPopu.this.checkedGoodsSpec, ChooseGoodsSpecPopu.this.checkedGoodsSpecId, Integer.valueOf(Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())));
                        }
                        return;
                    }
                    Toast.makeText(paramContext, "请输入购买数量", Toast.LENGTH_SHORT).show();
                }
            });
            this.buyNowBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    if (!"".equals(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())) {
                        if (ChooseGoodsSpecPopu.this.onClickBuyNowBtnListener != null) {
                            ChooseGoodsSpecPopu.this.onClickBuyNowBtnListener.OnClickBuyNowBtn(ChooseGoodsSpecPopu.this.checkedGoodsSpec, ChooseGoodsSpecPopu.this.checkedGoodsSpecId, Integer.valueOf(Integer.parseInt(ChooseGoodsSpecPopu.this.tvBuyNum.getText().toString().trim())), ChooseGoodsSpecPopu.this.isPresell);
                        }
                        return;
                    }
                    Toast.makeText(paramContext, "请输入购买数量", Toast.LENGTH_SHORT).show();
                }
            });
            setContentView(this.view);
            setWidth(-1);
            setHeight(-1);
            setFocusable(true);
            setAnimationStyle(R.style.AnimBottom);
            setBackgroundDrawable(null);
            this.textView.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    ChooseGoodsSpecPopu.this.dismiss();
                }
            });
            this.closeBtn.setOnClickListener(new OnClickListener() {
                public void onClick(View paramAnonymousView) {
                    ChooseGoodsSpecPopu.this.dismiss();
                }
            });
//            paramString.setVisibility(View.GONE);
            this.noGoodsNum.setVisibility(View.GONE);
            this.addShopCartBtn.setBackgroundResource(R.color.checkGreenColor);
            this.buyNowBtn.setBackgroundResource(R.color.orange);
            this.addShopCartBtn.setEnabled(true);
            this.buyNowBtn.setEnabled(true);
//            paramString.setVisibility(View.VISIBLE);
            this.noGoodsNum.setVisibility(View.GONE);
            this.addShopCartBtn.setBackgroundResource(R.color.checkGreenColor);
            this.buyNowBtn.setBackgroundResource(R.color.orange);
            this.addShopCartBtn.setEnabled(true);
            this.buyNowBtn.setEnabled(true);
//            paramString.setVisibility(View.VISIBLE);
        }
    }

//    public ChooseGoodsSpecPopu(final Context paramContext, String paramString, Integer paramInteger, final ShoppingCartModel.ResultDataBean.GoodsDetailsBean paramGoodsDetailsBean) {
//        super(paramContext);
//        this.isFromGoodsOrShopCart = paramInteger;
//        this.checkedGoodsSpec = paramString;
//        this.view = ((LayoutInflater) paramContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.choose_goods_spec_popup_layout, null);
//        this.textView = ((TextView) this.view.findViewById(R.id.shadow_part));
//        this.okBtn = ((TextView) this.view.findViewById(R.id.choose_spec_bottom_btn));
//        this.closeBtn = ((ImageView) this.view.findViewById(R.id.close_btn));
//        this.goodsSpecPrice = ((TextView) this.view.findViewById(R.id.goods_spec_price));
//        this.goodsSpecNo = ((TextView) this.view.findViewById(R.id.goods_spec_no));
//        this.goodsSpecImg = ((ImageView) this.view.findViewById(R.id.goods_spec_img));
//        RelativeLayout rlSpecNum = this.view.findViewById(R.id.choose_spec_num_layout);
//        this.goodsSpecificationRecyclerView = ((RecyclerView) this.view.findViewById(R.id.goods_spec_recycler_view));
//        int i = 0;
//        if (i < paramGoodsDetailsBean.getGoodsSpecificationDetails().size()) {
//            if (this.checkedGoodsSpec.equals(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getSpecifications())) {
//                this.isPresell = Integer.valueOf(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getGxcGoodsState());
//                this.goodsSpecPrice.setText(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getPrice() + "");
//                this.goodsSpecNo.setText((String) ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getIdentifier());
//                if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getGoodsDisplayPictures().size() <= 0) {
//                }
//                String str = ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(i)).getGoodsDisplayPictures().get(0)).getPicUrl();
//                Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load("http://117.158.178.202:8001/JLMIS/" + str).into(this.goodsSpecImg);
//            }
//            for (; ; ) {
//                i += 1;
//                break;
//                label461:
//                Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_lose_xs)).load(R.drawable.img_noimg_xs).into(this.goodsSpecImg);
//            }
//        }
//        if (paramInteger.intValue() == 0) {
//            paramString.setVisibility(View.VISIBLE);
//        }
//        for (; ; ) {
//            this.goodsSpecificationRecyclerView.setLayoutManager(new GridLayoutManager(paramContext, 3));
//            this.shopCartPageGoodsSpecificationAdapter = new ShopCartPageGoodsSpecificationAdapter(2131361883, paramGoodsDetailsBean.getGoodsSpecificationDetails());
//            this.shopCartPageGoodsSpecificationAdapter.setCheckedGoodsSpc(this.checkedGoodsSpec);
//            this.goodsSpecificationRecyclerView.setAdapter(this.shopCartPageGoodsSpecificationAdapter);
//            this.shopCartPageGoodsSpecificationAdapter.setOnItemClickListener(new OnItemClickListener() {
//                public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
//                    paramAnonymousBaseQuickAdapter = (TextView) paramAnonymousView.findViewById(R.id.goods_spec_detail);
//                    paramAnonymousBaseQuickAdapter.setBackgroundResource(R.drawable.bg_text_green_border);
//                    paramAnonymousBaseQuickAdapter.setTextColor(paramContext.getResources().getColor(R.color.checkGreenColor));
//                    if (("".equals(ChooseGoodsSpecPopu.this.checkedGoodsSpec)) || (!ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(paramAnonymousBaseQuickAdapter.getText().toString().trim()))) {
//                        ChooseGoodsSpecPopu.this.checkedGoodsSpec = paramAnonymousBaseQuickAdapter.getText().toString().trim();
//                        ChooseGoodsSpecPopu.this.checkedGoodsSpecId = Integer.valueOf(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getId());
//                        ChooseGoodsSpecPopu.access$002(ChooseGoodsSpecPopu.this, Integer.valueOf(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getGxcGoodsState()));
//                        ChooseGoodsSpecPopu.this.shopCartPageGoodsSpecificationAdapter.setCheckedGoodsSpc(ChooseGoodsSpecPopu.this.checkedGoodsSpec);
//                        ChooseGoodsSpecPopu.this.shopCartPageGoodsSpecificationAdapter.notifyDataSetChanged();
//                        paramAnonymousInt = 0;
//                        if (paramAnonymousInt < paramGoodsDetailsBean.getGoodsSpecificationDetails().size()) {
//                            if (ChooseGoodsSpecPopu.this.checkedGoodsSpec.equals(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getSpecifications())) {
//                                ChooseGoodsSpecPopu.this.goodsSpecPrice.setText(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getPrice() + "");
//                                ChooseGoodsSpecPopu.this.goodsSpecNo.setText((String) ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getIdentifier());
//                                if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getGoodsDisplayPictures().size() <= 0) {
//                                    break label435;
//                                }
//                                paramAnonymousBaseQuickAdapter = ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) paramGoodsDetailsBean.getGoodsSpecificationDetails().get(paramAnonymousInt)).getGoodsDisplayPictures().get(0)).getPicUrl();
//                                Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_noimg_xs)).load("http://117.158.178.202:8001/JLMIS/" + paramAnonymousBaseQuickAdapter).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
//                            }
//                            for (; ; ) {
//                                paramAnonymousInt += 1;
//                                break;
//                                label435:
//                                Glide.with(paramContext).asBitmap().apply(new RequestOptions().placeholder(R.drawable.img_noimg_xs).error(R.drawable.img_noimg_xs)).load(Integer.valueOf(R.drawable.img_noimg_xs)).into(ChooseGoodsSpecPopu.this.goodsSpecImg);
//                            }
//                        }
//                    }
//                }
//            });
//            this.okBtn.setOnClickListener(new OnClickListener() {
//                public void onClick(View paramAnonymousView) {
//                    if (ChooseGoodsSpecPopu.this.onClickOkBtnListener != null) {
//                        ChooseGoodsSpecPopu.this.onClickOkBtnListener.OnClickOkBtn(ChooseGoodsSpecPopu.this.checkedGoodsSpec, ChooseGoodsSpecPopu.this.checkedGoodsSpecId);
//                    }
//                }
//            });
//            setContentView(this.view);
//            setWidth(-1);
//            setHeight(-1);
//            setFocusable(true);
//            setAnimationStyle(R.style.AnimBottom);
//            setBackgroundDrawable(null);
//            this.textView.setOnClickListener(new OnClickListener() {
//                public void onClick(View paramAnonymousView) {
//                    ChooseGoodsSpecPopu.this.dismiss();
//                }
//            });
//            this.closeBtn.setOnClickListener(new OnClickListener() {
//                public void onClick(View paramAnonymousView) {
//                    ChooseGoodsSpecPopu.this.dismiss();
//                }
//            });
//            return;
//            paramString.setVisibility(View.GONE);
//        }
//    }

    private List<String> getData() {
        ArrayList localArrayList = new ArrayList();
        int i = 0;
        while (i < 3) {
            localArrayList.add("乐肴居冰皮麻糬规格" + i);
            i += 1;
        }
        return localArrayList;
    }

    public void setOnClickAddShopCartBtnListener(OnClickAddShopCartBtnListener paramOnClickAddShopCartBtnListener) {
        this.onClickAddShopCartBtnListener = paramOnClickAddShopCartBtnListener;
    }

    public void setOnClickBuyNowBtnListener(OnClickBuyNowBtnListener paramOnClickBuyNowBtnListener) {
        this.onClickBuyNowBtnListener = paramOnClickBuyNowBtnListener;
    }

    public void setOnClickGoodsSpecItemListener(OnClickGoodsSpecItemListener paramOnClickGoodsSpecItemListener) {
        this.onClickGoodsSpecItemListener = paramOnClickGoodsSpecItemListener;
    }

    public void setOnClickOkBtnListener(OnClickOkBtnListener paramOnClickOkBtnListener) {
        this.onClickOkBtnListener = paramOnClickOkBtnListener;
    }

    public static abstract interface OnClickAddShopCartBtnListener {
        public abstract void OnClickAddShopCartBtn(String paramString, Integer paramInteger1, Integer paramInteger2);
    }

    public static abstract interface OnClickBuyNowBtnListener {
        public abstract void OnClickBuyNowBtn(String paramString, Integer paramInteger1, Integer paramInteger2, Integer paramInteger3);
    }

    public static abstract interface OnClickGoodsSpecItemListener {
        public abstract void OnClickGoodsSpecItem(String paramString, Integer paramInteger1, Integer paramInteger2);
    }

    public static abstract interface OnClickOkBtnListener {
        public abstract void OnClickOkBtn(String paramString, Integer paramInteger);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/popu/ChooseGoodsSpecPopu.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */